#coding=utf-8
'''
Created on 2011-3-2

@author: WangJian
'''
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from interface import *
import logging
import os
from google.appengine.ext.webapp import template
from google.appengine.api import users
from photo import download, GetImage

class PublicPage(webapp.RequestHandler):
  def render(self, template_file, template_value):
      path = os.path.join(os.path.dirname(__file__), template_file)
      self.response.out.write(template.render(path, template_value))

class MainPage(PublicPage):
  def get(self):
      url = users.create_logout_url(self.request.uri)
      template_values = {'url':url,}
      self.render('template/login.html',template_values)

application = webapp.WSGIApplication([
  ('/',MainPage),
  ('/UserLogin', UserLogin),
  ('/UserRegister', UserRegister),
  ('/AddReply', AddReply),
  ('/PhotoAll',PhotoLibAll),
  ('/PhotoUpdate', PhotoUpdate),
  ('/InfoAll',InfoAll),
  ('/downLoad', download),
  ('/InfoUpdate', InfoUpdateXML),
  ('/(s)/([0-9]+)',GetImage),
], debug=True)

      
def main():
    run_wsgi_app(application)


if __name__ == '__main__':
    try:
        main()
    except Exception,e:
        logging.error(str(e))